package kingAI.core;
/**
 * Defines a player's hand at any time.
 * 2-10 are numbered cards, 11 is J, 12 is Q, 13 is K, 14 is A.
 * Indices 0 and 1 are not used.
 * 
 * @author Equilibrium
 * @version 1.0
 */
public class Hand {
	/**
	 * True if clubs 2~14 in hand.
	 */
	public boolean[] clubs;
	/**
	 * True if diamonds 2~14 in hand.
	 */
	public boolean[] diamonds;
	/**
	 * True if hearts 2~14 in hand.
	 */
	public boolean[] hearts;
	/**
	 * True if spades 2~14 in hand.
	 */
	public boolean[] spades;
	
	/*
	 * Constructs an empty hand.
	 */
	public Hand(){
		clubs = new boolean[15];
		diamonds = new boolean[15];
		hearts = new boolean[15];
		spades = new boolean[15];
	}
	
	private String printCards(boolean[] cards){
		String result="";
		for(int i=2;i<11;i++)
			if(cards[i])
				result+=i+" ";
		if(cards[11])
			result+="J ";
		if(cards[12])
			result+="Q ";
		if(cards[13])
			result+="K ";
		if(cards[14])
			result+="A ";
		return result+"\n";
	}
	
	public String toString(){
		String result = "";
		result += "Clubs: ";
		result += printCards(clubs);
		result += "Diamonds: ";
		result += printCards(diamonds);
		result += "Hearts: ";
		result += printCards(hearts);
		result += "Spades: ";
		result += printCards(spades);
		return result;
	}
}